from ninja import ModelSchema, Field, FilterSchema, Schema
from django.db.models import Q
from typing import Optional
from rest_framework.serializers import ModelSerializer

from models.models import OrderInfo, VipOrderInfo, AgentOrderInfo


class CreateOrderInfoSchema(Schema):
    """用户订单创建"""
    address_id: int = Field(default=0, description="地址")
    good_id: int = Field(default=0, description="商品")
    good_spec_id: int = Field(default=0, description="商品规格")
    good_number: int = Field(default=0, description="商品数量")


class CreateVipOrderSchema(Schema):
    """用户订单创建"""
    package_id: int = Field(default=0, description="vip套餐")


class AppletsOrderFiltersSchema(FilterSchema):
    """用户订单筛选"""
    name: Optional[str] = Field(default=None, description="订单名称", q="good__name__icontains")
    transaction_status: Optional[int] = Field(None, description="交易状态")
    delivery_status: Optional[int] = Field(None, description="配送状态")
    after_sales_status: Optional[int] = Field(None, description="售后状态")


class AppletsVipOrderFiltersSchema(FilterSchema):
    """用户订单筛选"""
    name: Optional[str] = Field(default=None, description="订单名称", q="package__name__icontains")
    transaction_status: Optional[int] = Field(None, description="交易状态")


class PayOrderByWaterSchema(Schema):
    """用户订单支付"""
    order_id: int = Field(default=0, description="订单id")
    water_type: int = Field(default=0, description="水类型 1为水滴，2为水卡")


class OrderRefundSchema(Schema):
    """用户订单退款"""
    order_id: str = Field(default=0, description="订单id")
    reason: str = Field(default="", description="退款原因")